package com.foxzzz.dynamic.programming;

import com.alibaba.fastjson.JSON;

import java.util.List;


public class Solution139 {
    public boolean wordBreak(String s, List<String> wordDict) {
        boolean[] dp = new boolean[s.length()];
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j <= i; j++) {

                if ((j-1<0||dp[j - 1]) && wordDict.contains(s.substring(j, i + 1))) {
                    dp[i] = true;
                }
            }
        }
        return dp[s.length() - 1];
    }

    public static void main(String[] args) {
        System.out.println(new Solution139().wordBreak("a", (List<String>) JSON.parse("[\"a\"]")));
    }
}
